import { defineStore } from "pinia";

export const useRequestStore = defineStore({
  id: "requestStore",
  state: () => ({
    networkListener: null,
    requestList: [],
    currentRequest: null,
  }),
  actions: {
    setListener(listener) {
      // TODO:
      this.networkListener = listener;
    },
    getListener() {
      return this.networkListener;
    },
    pushRequest(fullRequest) {
      this.requestList.push(fullRequest);
    },
    setCurrentRequest(request) {
      this.currentRequest = request;
    },
    clear() {
      this.requestList.length = 0;
      this.currentRequest = null;
    },
  },
});